use ::libc;
extern "C" {
    pub type sockaddr_x25;
    pub type sockaddr_ns;
    pub type sockaddr_iso;
    pub type sockaddr_ipx;
    pub type sockaddr_inarp;
    pub type sockaddr_eon;
    pub type sockaddr_dl;
    pub type sockaddr_ax25;
    pub type sockaddr_at;
    pub type _IO_wide_data;
    pub type _IO_codecvt;
    pub type _IO_marker;
    pub type event_base;
    pub type evbuffer;
    pub type bufferevent_ops;
    pub type args;
    pub type tmuxpeer;
    pub type hyperlinks;
    pub type screen_write_cline;
    pub type screen_sel;
    pub type screen_titles;
    pub type environ;
    pub type options;
    pub type format_tree;
    pub type input_ctx;
    pub type cmds;
    pub type tty_key;
    pub type tty_code;
    pub type format_job_tree;
    pub type control_state;
    pub type cmdq_list;
    pub type cmdq_item;
    pub type tmuxproc;
    fn socket(__domain: libc::c_int, __type: libc::c_int, __protocol: libc::c_int) -> libc::c_int;
    fn connect(__fd: libc::c_int, __addr: __CONST_SOCKADDR_ARG, __len: socklen_t) -> libc::c_int;
    fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void;
    fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void;
    fn strlen(_: *const libc::c_char) -> libc::c_ulong;
    fn strerror(_: libc::c_int) -> *mut libc::c_char;
    fn strsignal(__sig: libc::c_int) -> *mut libc::c_char;
    fn kill(__pid: __pid_t, __sig: libc::c_int) -> libc::c_int;
    fn sigemptyset(__set: *mut sigset_t) -> libc::c_int;
    fn sigaction(
        __sig: libc::c_int,
        __act: *const sigaction,
        __oact: *mut sigaction,
    ) -> libc::c_int;
    fn close(__fd: libc::c_int) -> libc::c_int;
    fn closefrom(__lowfd: libc::c_int);
    fn dup(__fd: libc::c_int) -> libc::c_int;
    static mut environ: *mut *mut libc::c_char;
    fn execl(__path: *const libc::c_char, __arg: *const libc::c_char, _: ...) -> libc::c_int;
    fn getpid() -> __pid_t;
    fn getppid() -> __pid_t;
    fn waitpid(__pid: __pid_t, __stat_loc: *mut libc::c_int, __options: libc::c_int) -> __pid_t;
    fn unlink(__name: *const libc::c_char) -> libc::c_int;
    fn isatty(__fd: libc::c_int) -> libc::c_int;
    fn ttyname(__fd: libc::c_int) -> *mut libc::c_char;
    fn flock(__fd: libc::c_int, __operation: libc::c_int) -> libc::c_int;
    fn open(__file: *const libc::c_char, __oflag: libc::c_int, _: ...) -> libc::c_int;
    fn __errno_location() -> *mut libc::c_int;
    fn free(_: *mut libc::c_void);
    fn getenv(__name: *const libc::c_char) -> *mut libc::c_char;
    fn setenv(
        __name: *const libc::c_char,
        __value: *const libc::c_char,
        __replace: libc::c_int,
    ) -> libc::c_int;
    fn system(__command: *const libc::c_char) -> libc::c_int;
    static mut stdin: *mut FILE;
    static mut stdout: *mut FILE;
    static mut stderr: *mut FILE;
    fn fflush(__stream: *mut FILE) -> libc::c_int;
    fn setvbuf(
        __stream: *mut FILE,
        __buf: *mut libc::c_char,
        __modes: libc::c_int,
        __n: size_t,
    ) -> libc::c_int;
    fn fprintf(_: *mut FILE, _: *const libc::c_char, _: ...) -> libc::c_int;
    fn printf(_: *const libc::c_char, _: ...) -> libc::c_int;
    fn getline(
        __lineptr: *mut *mut libc::c_char,
        __n: *mut size_t,
        __stream: *mut FILE,
    ) -> __ssize_t;
    fn cfgetospeed(__termios_p: *const termios) -> speed_t;
    fn cfgetispeed(__termios_p: *const termios) -> speed_t;
    fn cfsetospeed(__termios_p: *mut termios, __speed: speed_t) -> libc::c_int;
    fn cfsetispeed(__termios_p: *mut termios, __speed: speed_t) -> libc::c_int;
    fn tcgetattr(__fd: libc::c_int, __termios_p: *mut termios) -> libc::c_int;
    fn tcsetattr(
        __fd: libc::c_int,
        __optional_actions: libc::c_int,
        __termios_p: *const termios,
    ) -> libc::c_int;
    fn cfmakeraw(__termios_p: *mut termios);
    fn strlcpy(_: *mut libc::c_char, _: *const libc::c_char, _: size_t) -> size_t;
    fn xmalloc(_: size_t) -> *mut libc::c_void;
    fn xstrdup(_: *const libc::c_char) -> *mut libc::c_char;
    fn xasprintf(_: *mut *mut libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int;
    fn xsnprintf(_: *mut libc::c_char, _: size_t, _: *const libc::c_char, _: ...) -> libc::c_int;
    static mut global_options: *mut options;
    static mut global_s_options: *mut options;
    static mut global_w_options: *mut options;
    static mut global_environ: *mut environ;
    static mut socket_path: *const libc::c_char;
    static mut shell_command: *const libc::c_char;
    static mut ptm_fd: libc::c_int;
    fn setblocking(_: libc::c_int, _: libc::c_int);
    fn shell_argv0(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char;
    fn find_cwd() -> *const libc::c_char;
    fn find_home() -> *const libc::c_char;
    fn proc_send(
        _: *mut tmuxpeer,
        _: msgtype,
        _: libc::c_int,
        _: *const libc::c_void,
        _: size_t,
    ) -> libc::c_int;
    fn proc_start(_: *const libc::c_char) -> *mut tmuxproc;
    fn proc_loop(_: *mut tmuxproc, _: Option<unsafe extern "C" fn() -> libc::c_int>);
    fn proc_exit(_: *mut tmuxproc);
    fn proc_set_signals(_: *mut tmuxproc, _: Option<unsafe extern "C" fn(libc::c_int) -> ()>);
    fn proc_clear_signals(_: *mut tmuxproc, _: libc::c_int);
    fn proc_add_peer(
        _: *mut tmuxproc,
        _: libc::c_int,
        _: Option<unsafe extern "C" fn(*mut imsg, *mut libc::c_void) -> ()>,
        _: *mut libc::c_void,
    ) -> *mut tmuxpeer;
    fn proc_flush_peer(_: *mut tmuxpeer);
    fn environ_free(_: *mut environ);
    fn tty_term_read_list(
        _: *const libc::c_char,
        _: libc::c_int,
        _: *mut *mut *mut libc::c_char,
        _: *mut u_int,
        _: *mut *mut libc::c_char,
    ) -> libc::c_int;
    fn tty_term_free_list(_: *mut *mut libc::c_char, _: u_int);
    fn args_from_vector(_: libc::c_int, _: *mut *mut libc::c_char) -> *mut args_value;
    fn args_free_values(_: *mut args_value, _: u_int);
    fn cmd_pack_argv(
        _: libc::c_int,
        _: *mut *mut libc::c_char,
        _: *mut libc::c_char,
        _: size_t,
    ) -> libc::c_int;
    fn cmd_list_free(_: *mut cmd_list);
    fn cmd_list_any_have(_: *mut cmd_list, _: libc::c_int) -> libc::c_int;
    fn cmd_parse_from_arguments(
        _: *mut args_value,
        _: u_int,
        _: *mut cmd_parse_input,
    ) -> *mut cmd_parse_result;
    fn options_free(_: *mut options);
    fn file_write_close(_: *mut client_files, _: *mut imsg);
    fn file_write_data(_: *mut client_files, _: *mut imsg);
    fn file_write_left(_: *mut client_files) -> libc::c_int;
    fn file_write_open(
        _: *mut client_files,
        _: *mut tmuxpeer,
        _: *mut imsg,
        _: libc::c_int,
        _: libc::c_int,
        _: client_file_cb,
        _: *mut libc::c_void,
    );
    fn file_read_cancel(_: *mut client_files, _: *mut imsg);
    fn file_read_open(
        _: *mut client_files,
        _: *mut tmuxpeer,
        _: *mut imsg,
        _: libc::c_int,
        _: libc::c_int,
        _: client_file_cb,
        _: *mut libc::c_void,
    );
    fn server_start(
        _: *mut tmuxproc,
        _: uint64_t,
        _: *mut event_base,
        _: libc::c_int,
        _: *mut libc::c_char,
    ) -> libc::c_int;
    fn fatalx(_: *const libc::c_char, _: ...) -> !;
    fn log_debug(_: *const libc::c_char, _: ...);
    fn fatal(_: *const libc::c_char, _: ...) -> !;
}
pub type __u_char = libc::c_uchar;
pub type __u_short = libc::c_ushort;
pub type __u_int = libc::c_uint;
pub type __uint8_t = libc::c_uchar;
pub type __uint16_t = libc::c_ushort;
pub type __uint32_t = libc::c_uint;
pub type __uint64_t = libc::c_ulong;
pub type __uid_t = libc::c_uint;
pub type __off_t = libc::c_long;
pub type __off64_t = libc::c_long;
pub type __pid_t = libc::c_int;
pub type __clock_t = libc::c_long;
pub type __time_t = libc::c_long;
pub type __suseconds_t = libc::c_long;
pub type __ssize_t = libc::c_long;
pub type __socklen_t = libc::c_uint;
pub type u_char = __u_char;
pub type u_short = __u_short;
pub type u_int = __u_int;
pub type pid_t = __pid_t;
pub type ssize_t = __ssize_t;
pub type time_t = __time_t;
pub type size_t = libc::c_ulong;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __sigset_t {
    pub __val: [libc::c_ulong; 16],
}
pub type sigset_t = __sigset_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct timeval {
    pub tv_sec: __time_t,
    pub tv_usec: __suseconds_t,
}
pub type socklen_t = __socklen_t;
pub type __socket_type = libc::c_uint;
pub const SOCK_NONBLOCK: __socket_type = 2048;
pub const SOCK_CLOEXEC: __socket_type = 524288;
pub const SOCK_PACKET: __socket_type = 10;
pub const SOCK_DCCP: __socket_type = 6;
pub const SOCK_SEQPACKET: __socket_type = 5;
pub const SOCK_RDM: __socket_type = 4;
pub const SOCK_RAW: __socket_type = 3;
pub const SOCK_DGRAM: __socket_type = 2;
pub const SOCK_STREAM: __socket_type = 1;
pub type sa_family_t = libc::c_ushort;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sockaddr {
    pub sa_family: sa_family_t,
    pub sa_data: [libc::c_char; 14],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sockaddr_un {
    pub sun_family: sa_family_t,
    pub sun_path: [libc::c_char; 108],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sockaddr_in6 {
    pub sin6_family: sa_family_t,
    pub sin6_port: in_port_t,
    pub sin6_flowinfo: uint32_t,
    pub sin6_addr: in6_addr,
    pub sin6_scope_id: uint32_t,
}
pub type uint32_t = __uint32_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct in6_addr {
    pub __in6_u: C2RustUnnamed,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed {
    pub __u6_addr8: [uint8_t; 16],
    pub __u6_addr16: [uint16_t; 8],
    pub __u6_addr32: [uint32_t; 4],
}
pub type uint16_t = __uint16_t;
pub type uint8_t = __uint8_t;
pub type in_port_t = uint16_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sockaddr_in {
    pub sin_family: sa_family_t,
    pub sin_port: in_port_t,
    pub sin_addr: in_addr,
    pub sin_zero: [libc::c_uchar; 8],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct in_addr {
    pub s_addr: in_addr_t,
}
pub type in_addr_t = uint32_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub union __CONST_SOCKADDR_ARG {
    pub __sockaddr__: *const sockaddr,
    pub __sockaddr_at__: *const sockaddr_at,
    pub __sockaddr_ax25__: *const sockaddr_ax25,
    pub __sockaddr_dl__: *const sockaddr_dl,
    pub __sockaddr_eon__: *const sockaddr_eon,
    pub __sockaddr_in__: *const sockaddr_in,
    pub __sockaddr_in6__: *const sockaddr_in6,
    pub __sockaddr_inarp__: *const sockaddr_inarp,
    pub __sockaddr_ipx__: *const sockaddr_ipx,
    pub __sockaddr_iso__: *const sockaddr_iso,
    pub __sockaddr_ns__: *const sockaddr_ns,
    pub __sockaddr_un__: *const sockaddr_un,
    pub __sockaddr_x25__: *const sockaddr_x25,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union sigval {
    pub sival_int: libc::c_int,
    pub sival_ptr: *mut libc::c_void,
}
pub type __sigval_t = sigval;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct siginfo_t {
    pub si_signo: libc::c_int,
    pub si_errno: libc::c_int,
    pub si_code: libc::c_int,
    pub __pad0: libc::c_int,
    pub _sifields: C2RustUnnamed_0,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_0 {
    pub _pad: [libc::c_int; 28],
    pub _kill: C2RustUnnamed_9,
    pub _timer: C2RustUnnamed_8,
    pub _rt: C2RustUnnamed_7,
    pub _sigchld: C2RustUnnamed_6,
    pub _sigfault: C2RustUnnamed_3,
    pub _sigpoll: C2RustUnnamed_2,
    pub _sigsys: C2RustUnnamed_1,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_1 {
    pub _call_addr: *mut libc::c_void,
    pub _syscall: libc::c_int,
    pub _arch: libc::c_uint,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_2 {
    pub si_band: libc::c_long,
    pub si_fd: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_3 {
    pub si_addr: *mut libc::c_void,
    pub si_addr_lsb: libc::c_short,
    pub _bounds: C2RustUnnamed_4,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_4 {
    pub _addr_bnd: C2RustUnnamed_5,
    pub _pkey: __uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_5 {
    pub _lower: *mut libc::c_void,
    pub _upper: *mut libc::c_void,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_6 {
    pub si_pid: __pid_t,
    pub si_uid: __uid_t,
    pub si_status: libc::c_int,
    pub si_utime: __clock_t,
    pub si_stime: __clock_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_7 {
    pub si_pid: __pid_t,
    pub si_uid: __uid_t,
    pub si_sigval: __sigval_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_8 {
    pub si_tid: libc::c_int,
    pub si_overrun: libc::c_int,
    pub si_sigval: __sigval_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_9 {
    pub si_pid: __pid_t,
    pub si_uid: __uid_t,
}
pub type __sighandler_t = Option<unsafe extern "C" fn(libc::c_int) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sigaction {
    pub __sigaction_handler: C2RustUnnamed_10,
    pub sa_mask: __sigset_t,
    pub sa_flags: libc::c_int,
    pub sa_restorer: Option<unsafe extern "C" fn() -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_10 {
    pub sa_handler: __sighandler_t,
    pub sa_sigaction:
        Option<unsafe extern "C" fn(libc::c_int, *mut siginfo_t, *mut libc::c_void) -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _IO_FILE {
    pub _flags: libc::c_int,
    pub _IO_read_ptr: *mut libc::c_char,
    pub _IO_read_end: *mut libc::c_char,
    pub _IO_read_base: *mut libc::c_char,
    pub _IO_write_base: *mut libc::c_char,
    pub _IO_write_ptr: *mut libc::c_char,
    pub _IO_write_end: *mut libc::c_char,
    pub _IO_buf_base: *mut libc::c_char,
    pub _IO_buf_end: *mut libc::c_char,
    pub _IO_save_base: *mut libc::c_char,
    pub _IO_backup_base: *mut libc::c_char,
    pub _IO_save_end: *mut libc::c_char,
    pub _markers: *mut _IO_marker,
    pub _chain: *mut _IO_FILE,
    pub _fileno: libc::c_int,
    pub _flags2: libc::c_int,
    pub _old_offset: __off_t,
    pub _cur_column: libc::c_ushort,
    pub _vtable_offset: libc::c_schar,
    pub _shortbuf: [libc::c_char; 1],
    pub _lock: *mut libc::c_void,
    pub _offset: __off64_t,
    pub _codecvt: *mut _IO_codecvt,
    pub _wide_data: *mut _IO_wide_data,
    pub _freeres_list: *mut _IO_FILE,
    pub _freeres_buf: *mut libc::c_void,
    pub __pad5: size_t,
    pub _mode: libc::c_int,
    pub _unused2: [libc::c_char; 20],
}
pub type _IO_lock_t = ();
pub type FILE = _IO_FILE;
pub type cc_t = libc::c_uchar;
pub type speed_t = libc::c_uint;
pub type tcflag_t = libc::c_uint;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct termios {
    pub c_iflag: tcflag_t,
    pub c_oflag: tcflag_t,
    pub c_cflag: tcflag_t,
    pub c_lflag: tcflag_t,
    pub c_line: cc_t,
    pub c_cc: [cc_t; 32],
    pub c_ispeed: speed_t,
    pub c_ospeed: speed_t,
}
pub type uint64_t = __uint64_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event {
    pub ev_evcallback: event_callback,
    pub ev_timeout_pos: C2RustUnnamed_16,
    pub ev_fd: libc::c_int,
    pub ev_base: *mut event_base,
    pub ev_: C2RustUnnamed_11,
    pub ev_events: libc::c_short,
    pub ev_res: libc::c_short,
    pub ev_timeout: timeval,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_11 {
    pub ev_io: C2RustUnnamed_14,
    pub ev_signal: C2RustUnnamed_12,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_12 {
    pub ev_signal_next: C2RustUnnamed_13,
    pub ev_ncalls: libc::c_short,
    pub ev_pncalls: *mut libc::c_short,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_13 {
    pub le_next: *mut event,
    pub le_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_14 {
    pub ev_io_next: C2RustUnnamed_15,
    pub ev_timeout: timeval,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_15 {
    pub le_next: *mut event,
    pub le_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_16 {
    pub ev_next_with_common_timeout: C2RustUnnamed_17,
    pub min_heap_idx: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_17 {
    pub tqe_next: *mut event,
    pub tqe_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_callback {
    pub evcb_active_next: C2RustUnnamed_19,
    pub evcb_flags: libc::c_short,
    pub evcb_pri: uint8_t,
    pub evcb_closure: uint8_t,
    pub evcb_cb_union: C2RustUnnamed_18,
    pub evcb_arg: *mut libc::c_void,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_18 {
    pub evcb_callback:
        Option<unsafe extern "C" fn(libc::c_int, libc::c_short, *mut libc::c_void) -> ()>,
    pub evcb_selfcb: Option<unsafe extern "C" fn(*mut event_callback, *mut libc::c_void) -> ()>,
    pub evcb_evfinalize: Option<unsafe extern "C" fn(*mut event, *mut libc::c_void) -> ()>,
    pub evcb_cbfinalize: Option<unsafe extern "C" fn(*mut event_callback, *mut libc::c_void) -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_19 {
    pub tqe_next: *mut event_callback,
    pub tqe_prev: *mut *mut event_callback,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct bufferevent {
    pub ev_base: *mut event_base,
    pub be_ops: *const bufferevent_ops,
    pub ev_read: event,
    pub ev_write: event,
    pub input: *mut evbuffer,
    pub output: *mut evbuffer,
    pub wm_read: event_watermark,
    pub wm_write: event_watermark,
    pub readcb: bufferevent_data_cb,
    pub writecb: bufferevent_data_cb,
    pub errorcb: bufferevent_event_cb,
    pub cbarg: *mut libc::c_void,
    pub timeout_read: timeval,
    pub timeout_write: timeval,
    pub enabled: libc::c_short,
}
pub type bufferevent_event_cb =
    Option<unsafe extern "C" fn(*mut bufferevent, libc::c_short, *mut libc::c_void) -> ()>;
pub type bufferevent_data_cb =
    Option<unsafe extern "C" fn(*mut bufferevent, *mut libc::c_void) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_watermark {
    pub low: size_t,
    pub high: size_t,
}
pub type bitstr_t = libc::c_uchar;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ibuf {
    pub entry: C2RustUnnamed_20,
    pub buf: *mut libc::c_uchar,
    pub size: size_t,
    pub max: size_t,
    pub wpos: size_t,
    pub rpos: size_t,
    pub fd: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_20 {
    pub tqe_next: *mut ibuf,
    pub tqe_prev: *mut *mut ibuf,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct imsg_hdr {
    pub type_0: uint32_t,
    pub len: uint16_t,
    pub flags: uint16_t,
    pub peerid: uint32_t,
    pub pid: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct imsg {
    pub hdr: imsg_hdr,
    pub fd: libc::c_int,
    pub data: *mut libc::c_void,
    pub buf: *mut ibuf,
}
pub type msgtype = libc::c_uint;
pub const MSG_READ_CANCEL: msgtype = 307;
pub const MSG_WRITE_CLOSE: msgtype = 306;
pub const MSG_WRITE_READY: msgtype = 305;
pub const MSG_WRITE: msgtype = 304;
pub const MSG_WRITE_OPEN: msgtype = 303;
pub const MSG_READ_DONE: msgtype = 302;
pub const MSG_READ: msgtype = 301;
pub const MSG_READ_OPEN: msgtype = 300;
pub const MSG_FLAGS: msgtype = 218;
pub const MSG_EXEC: msgtype = 217;
pub const MSG_WAKEUP: msgtype = 216;
pub const MSG_UNLOCK: msgtype = 215;
pub const MSG_SUSPEND: msgtype = 214;
pub const MSG_OLDSTDOUT: msgtype = 213;
pub const MSG_OLDSTDIN: msgtype = 212;
pub const MSG_OLDSTDERR: msgtype = 211;
pub const MSG_SHUTDOWN: msgtype = 210;
pub const MSG_SHELL: msgtype = 209;
pub const MSG_RESIZE: msgtype = 208;
pub const MSG_READY: msgtype = 207;
pub const MSG_LOCK: msgtype = 206;
pub const MSG_EXITING: msgtype = 205;
pub const MSG_EXITED: msgtype = 204;
pub const MSG_EXIT: msgtype = 203;
pub const MSG_DETACHKILL: msgtype = 202;
pub const MSG_DETACH: msgtype = 201;
pub const MSG_COMMAND: msgtype = 200;
pub const MSG_IDENTIFY_TERMINFO: msgtype = 112;
pub const MSG_IDENTIFY_LONGFLAGS: msgtype = 111;
pub const MSG_IDENTIFY_STDOUT: msgtype = 110;
pub const MSG_IDENTIFY_FEATURES: msgtype = 109;
pub const MSG_IDENTIFY_CWD: msgtype = 108;
pub const MSG_IDENTIFY_CLIENTPID: msgtype = 107;
pub const MSG_IDENTIFY_DONE: msgtype = 106;
pub const MSG_IDENTIFY_ENVIRON: msgtype = 105;
pub const MSG_IDENTIFY_STDIN: msgtype = 104;
pub const MSG_IDENTIFY_OLDCWD: msgtype = 103;
pub const MSG_IDENTIFY_TTYNAME: msgtype = 102;
pub const MSG_IDENTIFY_TERM: msgtype = 101;
pub const MSG_IDENTIFY_FLAGS: msgtype = 100;
pub const MSG_VERSION: msgtype = 12;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct msg_command {
    pub argc: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client {
    pub name: *const libc::c_char,
    pub peer: *mut tmuxpeer,
    pub queue: *mut cmdq_list,
    pub windows: client_windows,
    pub control_state: *mut control_state,
    pub pause_age: u_int,
    pub pid: pid_t,
    pub fd: libc::c_int,
    pub out_fd: libc::c_int,
    pub event: event,
    pub retval: libc::c_int,
    pub creation_time: timeval,
    pub activity_time: timeval,
    pub last_activity_time: timeval,
    pub environ: *mut environ,
    pub jobs: *mut format_job_tree,
    pub title: *mut libc::c_char,
    pub path: *mut libc::c_char,
    pub cwd: *const libc::c_char,
    pub term_name: *mut libc::c_char,
    pub term_features: libc::c_int,
    pub term_type: *mut libc::c_char,
    pub term_caps: *mut *mut libc::c_char,
    pub term_ncaps: u_int,
    pub ttyname: *mut libc::c_char,
    pub tty: tty,
    pub written: size_t,
    pub discarded: size_t,
    pub redraw: size_t,
    pub repeat_timer: event,
    pub click_timer: event,
    pub click_button: u_int,
    pub click_event: mouse_event,
    pub status: status_line,
    pub flags: uint64_t,
    pub exit_type: C2RustUnnamed_43,
    pub exit_msgtype: msgtype,
    pub exit_session: *mut libc::c_char,
    pub exit_message: *mut libc::c_char,
    pub keytable: *mut key_table,
    pub last_key: key_code,
    pub redraw_panes: uint64_t,
    pub redraw_scrollbars: uint64_t,
    pub message_ignore_keys: libc::c_int,
    pub message_ignore_styles: libc::c_int,
    pub message_string: *mut libc::c_char,
    pub message_timer: event,
    pub prompt_string: *mut libc::c_char,
    pub prompt_buffer: *mut utf8_data,
    pub prompt_last: *mut libc::c_char,
    pub prompt_index: size_t,
    pub prompt_inputcb: prompt_input_cb,
    pub prompt_freecb: prompt_free_cb,
    pub prompt_data: *mut libc::c_void,
    pub prompt_hindex: [u_int; 4],
    pub prompt_mode: C2RustUnnamed_40,
    pub prompt_saved: *mut utf8_data,
    pub prompt_flags: libc::c_int,
    pub prompt_type: prompt_type,
    pub prompt_cursor: libc::c_int,
    pub session: *mut session,
    pub last_session: *mut session,
    pub references: libc::c_int,
    pub pan_window: *mut libc::c_void,
    pub pan_ox: u_int,
    pub pan_oy: u_int,
    pub overlay_check: overlay_check_cb,
    pub overlay_mode: overlay_mode_cb,
    pub overlay_draw: overlay_draw_cb,
    pub overlay_key: overlay_key_cb,
    pub overlay_free: overlay_free_cb,
    pub overlay_resize: overlay_resize_cb,
    pub overlay_data: *mut libc::c_void,
    pub overlay_timer: event,
    pub files: client_files,
    pub clipboard_panes: *mut u_int,
    pub clipboard_npanes: u_int,
    pub entry: C2RustUnnamed_21,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_21 {
    pub tqe_next: *mut client,
    pub tqe_prev: *mut *mut client,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_files {
    pub rbh_root: *mut client_file,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_file {
    pub c: *mut client,
    pub peer: *mut tmuxpeer,
    pub tree: *mut client_files,
    pub references: libc::c_int,
    pub stream: libc::c_int,
    pub path: *mut libc::c_char,
    pub buffer: *mut evbuffer,
    pub event: *mut bufferevent,
    pub fd: libc::c_int,
    pub error: libc::c_int,
    pub closed: libc::c_int,
    pub cb: client_file_cb,
    pub data: *mut libc::c_void,
    pub entry: C2RustUnnamed_22,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_22 {
    pub rbe_left: *mut client_file,
    pub rbe_right: *mut client_file,
    pub rbe_parent: *mut client_file,
    pub rbe_color: libc::c_int,
}
pub type client_file_cb = Option<
    unsafe extern "C" fn(
        *mut client,
        *const libc::c_char,
        libc::c_int,
        libc::c_int,
        *mut evbuffer,
        *mut libc::c_void,
    ) -> (),
>;
pub type overlay_resize_cb = Option<unsafe extern "C" fn(*mut client, *mut libc::c_void) -> ()>;
pub type overlay_free_cb = Option<unsafe extern "C" fn(*mut client, *mut libc::c_void) -> ()>;
pub type overlay_key_cb =
    Option<unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut key_event) -> libc::c_int>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_event {
    pub key: key_code,
    pub m: mouse_event,
    pub buf: *mut libc::c_char,
    pub len: size_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct mouse_event {
    pub valid: libc::c_int,
    pub ignore: libc::c_int,
    pub key: key_code,
    pub statusat: libc::c_int,
    pub statuslines: u_int,
    pub x: u_int,
    pub y: u_int,
    pub b: u_int,
    pub lx: u_int,
    pub ly: u_int,
    pub lb: u_int,
    pub ox: u_int,
    pub oy: u_int,
    pub s: libc::c_int,
    pub w: libc::c_int,
    pub wp: libc::c_int,
    pub sgr_type: u_int,
    pub sgr_b: u_int,
}
pub type key_code = libc::c_ulonglong;
pub type overlay_draw_cb =
    Option<unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut screen_redraw_ctx) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct screen_redraw_ctx {
    pub c: *mut client,
    pub statuslines: u_int,
    pub statustop: libc::c_int,
    pub pane_status: libc::c_int,
    pub pane_lines: pane_lines,
    pub pane_scrollbars: libc::c_int,
    pub pane_scrollbars_pos: libc::c_int,
    pub no_pane_gc: grid_cell,
    pub no_pane_gc_set: libc::c_int,
    pub sx: u_int,
    pub sy: u_int,
    pub ox: u_int,
    pub oy: u_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid_cell {
    pub data: utf8_data,
    pub attr: u_short,
    pub flags: u_char,
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub us: libc::c_int,
    pub link: u_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct utf8_data {
    pub data: [u_char; 21],
    pub have: u_char,
    pub size: u_char,
    pub width: u_char,
}
pub type pane_lines = libc::c_uint;
pub const PANE_LINES_NUMBER: pane_lines = 4;
pub const PANE_LINES_SIMPLE: pane_lines = 3;
pub const PANE_LINES_HEAVY: pane_lines = 2;
pub const PANE_LINES_DOUBLE: pane_lines = 1;
pub const PANE_LINES_SINGLE: pane_lines = 0;
pub type overlay_mode_cb = Option<
    unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut u_int, *mut u_int) -> *mut screen,
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct screen {
    pub title: *mut libc::c_char,
    pub path: *mut libc::c_char,
    pub titles: *mut screen_titles,
    pub grid: *mut grid,
    pub cx: u_int,
    pub cy: u_int,
    pub cstyle: screen_cursor_style,
    pub default_cstyle: screen_cursor_style,
    pub ccolour: libc::c_int,
    pub default_ccolour: libc::c_int,
    pub rupper: u_int,
    pub rlower: u_int,
    pub mode: libc::c_int,
    pub default_mode: libc::c_int,
    pub saved_cx: u_int,
    pub saved_cy: u_int,
    pub saved_grid: *mut grid,
    pub saved_cell: grid_cell,
    pub saved_flags: libc::c_int,
    pub tabs: *mut bitstr_t,
    pub sel: *mut screen_sel,
    pub write_list: *mut screen_write_cline,
    pub hyperlinks: *mut hyperlinks,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid {
    pub flags: libc::c_int,
    pub sx: u_int,
    pub sy: u_int,
    pub hscrolled: u_int,
    pub hsize: u_int,
    pub hlimit: u_int,
    pub linedata: *mut grid_line,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid_line {
    pub celldata: *mut grid_cell_entry,
    pub cellused: u_int,
    pub cellsize: u_int,
    pub extddata: *mut grid_extd_entry,
    pub extdsize: u_int,
    pub flags: libc::c_int,
    pub time: time_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct grid_extd_entry {
    pub data: utf8_char,
    pub attr: u_short,
    pub flags: u_char,
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub us: libc::c_int,
    pub link: u_int,
}
pub type utf8_char = u_int;
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct grid_cell_entry {
    pub c2rust_unnamed: C2RustUnnamed_23,
    pub flags: u_char,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_23 {
    pub offset: u_int,
    pub data: C2RustUnnamed_24,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_24 {
    pub attr: u_char,
    pub fg: u_char,
    pub bg: u_char,
    pub data: u_char,
}
pub type screen_cursor_style = libc::c_uint;
pub const SCREEN_CURSOR_BAR: screen_cursor_style = 3;
pub const SCREEN_CURSOR_UNDERLINE: screen_cursor_style = 2;
pub const SCREEN_CURSOR_BLOCK: screen_cursor_style = 1;
pub const SCREEN_CURSOR_DEFAULT: screen_cursor_style = 0;
pub type overlay_check_cb = Option<
    unsafe extern "C" fn(
        *mut client,
        *mut libc::c_void,
        u_int,
        u_int,
        u_int,
        *mut overlay_ranges,
    ) -> (),
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct overlay_ranges {
    pub px: [u_int; 3],
    pub nx: [u_int; 3],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct session {
    pub id: u_int,
    pub name: *mut libc::c_char,
    pub cwd: *const libc::c_char,
    pub creation_time: timeval,
    pub last_attached_time: timeval,
    pub activity_time: timeval,
    pub last_activity_time: timeval,
    pub lock_timer: event,
    pub curw: *mut winlink,
    pub lastw: winlink_stack,
    pub windows: winlinks,
    pub statusat: libc::c_int,
    pub statuslines: u_int,
    pub options: *mut options,
    pub flags: libc::c_int,
    pub attached: u_int,
    pub tio: *mut termios,
    pub environ: *mut environ,
    pub references: libc::c_int,
    pub gentry: C2RustUnnamed_26,
    pub entry: C2RustUnnamed_25,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_25 {
    pub rbe_left: *mut session,
    pub rbe_right: *mut session,
    pub rbe_parent: *mut session,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_26 {
    pub tqe_next: *mut session,
    pub tqe_prev: *mut *mut session,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlinks {
    pub rbh_root: *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlink {
    pub idx: libc::c_int,
    pub session: *mut session,
    pub window: *mut window,
    pub flags: libc::c_int,
    pub entry: C2RustUnnamed_29,
    pub wentry: C2RustUnnamed_28,
    pub sentry: C2RustUnnamed_27,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_27 {
    pub tqe_next: *mut winlink,
    pub tqe_prev: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_28 {
    pub tqe_next: *mut winlink,
    pub tqe_prev: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_29 {
    pub rbe_left: *mut winlink,
    pub rbe_right: *mut winlink,
    pub rbe_parent: *mut winlink,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window {
    pub id: u_int,
    pub latest: *mut libc::c_void,
    pub name: *mut libc::c_char,
    pub name_event: event,
    pub name_time: timeval,
    pub alerts_timer: event,
    pub offset_timer: event,
    pub activity_time: timeval,
    pub active: *mut window_pane,
    pub last_panes: window_panes,
    pub panes: window_panes,
    pub lastlayout: libc::c_int,
    pub layout_root: *mut layout_cell,
    pub saved_layout_root: *mut layout_cell,
    pub old_layout: *mut libc::c_char,
    pub sx: u_int,
    pub sy: u_int,
    pub manual_sx: u_int,
    pub manual_sy: u_int,
    pub xpixel: u_int,
    pub ypixel: u_int,
    pub new_sx: u_int,
    pub new_sy: u_int,
    pub new_xpixel: u_int,
    pub new_ypixel: u_int,
    pub fill_character: *mut utf8_data,
    pub flags: libc::c_int,
    pub alerts_queued: libc::c_int,
    pub alerts_entry: C2RustUnnamed_32,
    pub options: *mut options,
    pub references: u_int,
    pub winlinks: C2RustUnnamed_31,
    pub entry: C2RustUnnamed_30,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_30 {
    pub rbe_left: *mut window,
    pub rbe_right: *mut window,
    pub rbe_parent: *mut window,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_31 {
    pub tqh_first: *mut winlink,
    pub tqh_last: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_32 {
    pub tqe_next: *mut window,
    pub tqe_prev: *mut *mut window,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct layout_cell {
    pub type_0: layout_type,
    pub parent: *mut layout_cell,
    pub sx: u_int,
    pub sy: u_int,
    pub xoff: u_int,
    pub yoff: u_int,
    pub wp: *mut window_pane,
    pub cells: layout_cells,
    pub entry: C2RustUnnamed_33,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_33 {
    pub tqe_next: *mut layout_cell,
    pub tqe_prev: *mut *mut layout_cell,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct layout_cells {
    pub tqh_first: *mut layout_cell,
    pub tqh_last: *mut *mut layout_cell,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane {
    pub id: u_int,
    pub active_point: u_int,
    pub window: *mut window,
    pub options: *mut options,
    pub layout_cell: *mut layout_cell,
    pub saved_layout_cell: *mut layout_cell,
    pub sx: u_int,
    pub sy: u_int,
    pub xoff: u_int,
    pub yoff: u_int,
    pub flags: libc::c_int,
    pub sb_slider_y: u_int,
    pub sb_slider_h: u_int,
    pub argc: libc::c_int,
    pub argv: *mut *mut libc::c_char,
    pub shell: *mut libc::c_char,
    pub cwd: *mut libc::c_char,
    pub pid: pid_t,
    pub tty: [libc::c_char; 32],
    pub status: libc::c_int,
    pub dead_time: timeval,
    pub fd: libc::c_int,
    pub event: *mut bufferevent,
    pub offset: window_pane_offset,
    pub base_offset: size_t,
    pub resize_queue: window_pane_resizes,
    pub resize_timer: event,
    pub ictx: *mut input_ctx,
    pub cached_gc: grid_cell,
    pub cached_active_gc: grid_cell,
    pub palette: colour_palette,
    pub pipe_fd: libc::c_int,
    pub pipe_event: *mut bufferevent,
    pub pipe_offset: window_pane_offset,
    pub screen: *mut screen,
    pub base: screen,
    pub status_screen: screen,
    pub status_size: size_t,
    pub modes: C2RustUnnamed_37,
    pub searchstr: *mut libc::c_char,
    pub searchregex: libc::c_int,
    pub border_gc_set: libc::c_int,
    pub border_gc: grid_cell,
    pub control_bg: libc::c_int,
    pub control_fg: libc::c_int,
    pub scrollbar_style: style,
    pub entry: C2RustUnnamed_36,
    pub sentry: C2RustUnnamed_35,
    pub tree_entry: C2RustUnnamed_34,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_34 {
    pub rbe_left: *mut window_pane,
    pub rbe_right: *mut window_pane,
    pub rbe_parent: *mut window_pane,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_35 {
    pub tqe_next: *mut window_pane,
    pub tqe_prev: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_36 {
    pub tqe_next: *mut window_pane,
    pub tqe_prev: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style {
    pub gc: grid_cell,
    pub ignore: libc::c_int,
    pub fill: libc::c_int,
    pub align: style_align,
    pub list: style_list,
    pub range_type: style_range_type,
    pub range_argument: u_int,
    pub range_string: [libc::c_char; 16],
    pub width: libc::c_int,
    pub pad: libc::c_int,
    pub default_type: style_default_type,
}
pub type style_default_type = libc::c_uint;
pub const STYLE_DEFAULT_POP: style_default_type = 2;
pub const STYLE_DEFAULT_PUSH: style_default_type = 1;
pub const STYLE_DEFAULT_BASE: style_default_type = 0;
pub type style_range_type = libc::c_uint;
pub const STYLE_RANGE_USER: style_range_type = 6;
pub const STYLE_RANGE_SESSION: style_range_type = 5;
pub const STYLE_RANGE_WINDOW: style_range_type = 4;
pub const STYLE_RANGE_PANE: style_range_type = 3;
pub const STYLE_RANGE_RIGHT: style_range_type = 2;
pub const STYLE_RANGE_LEFT: style_range_type = 1;
pub const STYLE_RANGE_NONE: style_range_type = 0;
pub type style_list = libc::c_uint;
pub const STYLE_LIST_RIGHT_MARKER: style_list = 4;
pub const STYLE_LIST_LEFT_MARKER: style_list = 3;
pub const STYLE_LIST_FOCUS: style_list = 2;
pub const STYLE_LIST_ON: style_list = 1;
pub const STYLE_LIST_OFF: style_list = 0;
pub type style_align = libc::c_uint;
pub const STYLE_ALIGN_ABSOLUTE_CENTRE: style_align = 4;
pub const STYLE_ALIGN_RIGHT: style_align = 3;
pub const STYLE_ALIGN_CENTRE: style_align = 2;
pub const STYLE_ALIGN_LEFT: style_align = 1;
pub const STYLE_ALIGN_DEFAULT: style_align = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_37 {
    pub tqh_first: *mut window_mode_entry,
    pub tqh_last: *mut *mut window_mode_entry,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_mode_entry {
    pub wp: *mut window_pane,
    pub swp: *mut window_pane,
    pub mode: *const window_mode,
    pub data: *mut libc::c_void,
    pub screen: *mut screen,
    pub prefix: u_int,
    pub entry: C2RustUnnamed_38,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_38 {
    pub tqe_next: *mut window_mode_entry,
    pub tqe_prev: *mut *mut window_mode_entry,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_mode {
    pub name: *const libc::c_char,
    pub default_format: *const libc::c_char,
    pub init: Option<
        unsafe extern "C" fn(*mut window_mode_entry, *mut cmd_find_state, *mut args) -> *mut screen,
    >,
    pub free: Option<unsafe extern "C" fn(*mut window_mode_entry) -> ()>,
    pub resize: Option<unsafe extern "C" fn(*mut window_mode_entry, u_int, u_int) -> ()>,
    pub update: Option<unsafe extern "C" fn(*mut window_mode_entry) -> ()>,
    pub key: Option<
        unsafe extern "C" fn(
            *mut window_mode_entry,
            *mut client,
            *mut session,
            *mut winlink,
            key_code,
            *mut mouse_event,
        ) -> (),
    >,
    pub key_table: Option<unsafe extern "C" fn(*mut window_mode_entry) -> *const libc::c_char>,
    pub command: Option<
        unsafe extern "C" fn(
            *mut window_mode_entry,
            *mut client,
            *mut session,
            *mut winlink,
            *mut args,
            *mut mouse_event,
        ) -> (),
    >,
    pub formats: Option<unsafe extern "C" fn(*mut window_mode_entry, *mut format_tree) -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cmd_find_state {
    pub flags: libc::c_int,
    pub current: *mut cmd_find_state,
    pub s: *mut session,
    pub wl: *mut winlink,
    pub w: *mut window,
    pub wp: *mut window_pane,
    pub idx: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_offset {
    pub used: size_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct colour_palette {
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub palette: *mut libc::c_int,
    pub default_palette: *mut libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_resizes {
    pub tqh_first: *mut window_pane_resize,
    pub tqh_last: *mut *mut window_pane_resize,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_resize {
    pub sx: u_int,
    pub sy: u_int,
    pub osx: u_int,
    pub osy: u_int,
    pub entry: C2RustUnnamed_39,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_39 {
    pub tqe_next: *mut window_pane_resize,
    pub tqe_prev: *mut *mut window_pane_resize,
}
pub type layout_type = libc::c_uint;
pub const LAYOUT_WINDOWPANE: layout_type = 2;
pub const LAYOUT_TOPBOTTOM: layout_type = 1;
pub const LAYOUT_LEFTRIGHT: layout_type = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_panes {
    pub tqh_first: *mut window_pane,
    pub tqh_last: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlink_stack {
    pub tqh_first: *mut winlink,
    pub tqh_last: *mut *mut winlink,
}
pub type prompt_type = libc::c_uint;
pub const PROMPT_TYPE_INVALID: prompt_type = 255;
pub const PROMPT_TYPE_WINDOW_TARGET: prompt_type = 3;
pub const PROMPT_TYPE_TARGET: prompt_type = 2;
pub const PROMPT_TYPE_SEARCH: prompt_type = 1;
pub const PROMPT_TYPE_COMMAND: prompt_type = 0;
pub type C2RustUnnamed_40 = libc::c_uint;
pub const PROMPT_COMMAND: C2RustUnnamed_40 = 1;
pub const PROMPT_ENTRY: C2RustUnnamed_40 = 0;
pub type prompt_free_cb = Option<unsafe extern "C" fn(*mut libc::c_void) -> ()>;
pub type prompt_input_cb = Option<
    unsafe extern "C" fn(
        *mut client,
        *mut libc::c_void,
        *const libc::c_char,
        libc::c_int,
    ) -> libc::c_int,
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_table {
    pub name: *const libc::c_char,
    pub activity_time: timeval,
    pub key_bindings: key_bindings,
    pub default_key_bindings: key_bindings,
    pub references: u_int,
    pub entry: C2RustUnnamed_41,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_41 {
    pub rbe_left: *mut key_table,
    pub rbe_right: *mut key_table,
    pub rbe_parent: *mut key_table,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_bindings {
    pub rbh_root: *mut key_binding,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_binding {
    pub key: key_code,
    pub cmdlist: *mut cmd_list,
    pub note: *const libc::c_char,
    pub flags: libc::c_int,
    pub entry: C2RustUnnamed_42,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_42 {
    pub rbe_left: *mut key_binding,
    pub rbe_right: *mut key_binding,
    pub rbe_parent: *mut key_binding,
    pub rbe_color: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cmd_list {
    pub references: libc::c_int,
    pub group: u_int,
    pub list: *mut cmds,
}
pub type C2RustUnnamed_43 = libc::c_uint;
pub const CLIENT_EXIT_DETACH: C2RustUnnamed_43 = 2;
pub const CLIENT_EXIT_SHUTDOWN: C2RustUnnamed_43 = 1;
pub const CLIENT_EXIT_RETURN: C2RustUnnamed_43 = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct status_line {
    pub timer: event,
    pub screen: screen,
    pub active: *mut screen,
    pub references: libc::c_int,
    pub style: grid_cell,
    pub entries: [status_line_entry; 5],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct status_line_entry {
    pub expanded: *mut libc::c_char,
    pub ranges: style_ranges,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style_ranges {
    pub tqh_first: *mut style_range,
    pub tqh_last: *mut *mut style_range,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style_range {
    pub type_0: style_range_type,
    pub argument: u_int,
    pub string: [libc::c_char; 16],
    pub start: u_int,
    pub end: u_int,
    pub entry: C2RustUnnamed_44,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_44 {
    pub tqe_next: *mut style_range,
    pub tqe_prev: *mut *mut style_range,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tty {
    pub client: *mut client,
    pub start_timer: event,
    pub clipboard_timer: event,
    pub last_requests: time_t,
    pub sx: u_int,
    pub sy: u_int,
    pub xpixel: u_int,
    pub ypixel: u_int,
    pub cx: u_int,
    pub cy: u_int,
    pub cstyle: screen_cursor_style,
    pub ccolour: libc::c_int,
    pub oflag: libc::c_int,
    pub oox: u_int,
    pub ooy: u_int,
    pub osx: u_int,
    pub osy: u_int,
    pub mode: libc::c_int,
    pub fg: libc::c_int,
    pub bg: libc::c_int,
    pub rlower: u_int,
    pub rupper: u_int,
    pub rleft: u_int,
    pub rright: u_int,
    pub event_in: event,
    pub in_0: *mut evbuffer,
    pub event_out: event,
    pub out: *mut evbuffer,
    pub timer: event,
    pub discarded: size_t,
    pub tio: termios,
    pub cell: grid_cell,
    pub last_cell: grid_cell,
    pub flags: libc::c_int,
    pub term: *mut tty_term,
    pub mouse_last_x: u_int,
    pub mouse_last_y: u_int,
    pub mouse_last_b: u_int,
    pub mouse_drag_flag: libc::c_int,
    pub mouse_scrolling_flag: libc::c_int,
    pub mouse_slider_mpos: libc::c_int,
    pub mouse_drag_update: Option<unsafe extern "C" fn(*mut client, *mut mouse_event) -> ()>,
    pub mouse_drag_release: Option<unsafe extern "C" fn(*mut client, *mut mouse_event) -> ()>,
    pub key_timer: event,
    pub key_tree: *mut tty_key,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tty_term {
    pub name: *mut libc::c_char,
    pub tty: *mut tty,
    pub features: libc::c_int,
    pub acs: [[libc::c_char; 2]; 256],
    pub codes: *mut tty_code,
    pub flags: libc::c_int,
    pub entry: C2RustUnnamed_45,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_45 {
    pub le_next: *mut tty_term,
    pub le_prev: *mut *mut tty_term,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_windows {
    pub rbh_root: *mut client_window,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_window {
    pub window: u_int,
    pub pane: *mut window_pane,
    pub sx: u_int,
    pub sy: u_int,
    pub entry: C2RustUnnamed_46,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_46 {
    pub rbe_left: *mut client_window,
    pub rbe_right: *mut client_window,
    pub rbe_parent: *mut client_window,
    pub rbe_color: libc::c_int,
}
pub type args_type = libc::c_uint;
pub const ARGS_COMMANDS: args_type = 2;
pub const ARGS_STRING: args_type = 1;
pub const ARGS_NONE: args_type = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct args_value {
    pub type_0: args_type,
    pub c2rust_unnamed: C2RustUnnamed_48,
    pub cached: *mut libc::c_char,
    pub entry: C2RustUnnamed_47,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_47 {
    pub tqe_next: *mut args_value,
    pub tqe_prev: *mut *mut args_value,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_48 {
    pub string: *mut libc::c_char,
    pub cmdlist: *mut cmd_list,
}
pub type cmd_parse_status = libc::c_uint;
pub const CMD_PARSE_SUCCESS: cmd_parse_status = 1;
pub const CMD_PARSE_ERROR: cmd_parse_status = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cmd_parse_result {
    pub status: cmd_parse_status,
    pub cmdlist: *mut cmd_list,
    pub error: *mut libc::c_char,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cmd_parse_input {
    pub flags: libc::c_int,
    pub file: *const libc::c_char,
    pub line: u_int,
    pub item: *mut cmdq_item,
    pub c: *mut client,
    pub fs: cmd_find_state,
}
pub const CLIENT_EXIT_MESSAGE_PROVIDED: C2RustUnnamed_49 = 8;
pub const CLIENT_EXIT_SERVER_EXITED: C2RustUnnamed_49 = 7;
pub const CLIENT_EXIT_EXITED: C2RustUnnamed_49 = 6;
pub const CLIENT_EXIT_LOST_SERVER: C2RustUnnamed_49 = 5;
pub const CLIENT_EXIT_TERMINATED: C2RustUnnamed_49 = 4;
pub const CLIENT_EXIT_LOST_TTY: C2RustUnnamed_49 = 3;
pub const CLIENT_EXIT_DETACHED_HUP: C2RustUnnamed_49 = 2;
pub const CLIENT_EXIT_DETACHED: C2RustUnnamed_49 = 1;
pub const CLIENT_EXIT_NONE: C2RustUnnamed_49 = 0;
pub type C2RustUnnamed_49 = libc::c_uint;
static mut client_proc: *mut tmuxproc = 0 as *const tmuxproc as *mut tmuxproc;
static mut client_peer: *mut tmuxpeer = 0 as *const tmuxpeer as *mut tmuxpeer;
static mut client_flags: uint64_t = 0;
static mut client_suspended: libc::c_int = 0;
static mut client_exitreason: C2RustUnnamed_49 = CLIENT_EXIT_NONE;
static mut client_exitflag: libc::c_int = 0;
static mut client_exitval: libc::c_int = 0;
static mut client_exittype: msgtype = 0 as msgtype;
static mut client_exitsession: *const libc::c_char = 0 as *const libc::c_char;
static mut client_exitmessage: *mut libc::c_char = 0 as *const libc::c_char as *mut libc::c_char;
static mut client_execshell: *const libc::c_char = 0 as *const libc::c_char;
static mut client_execcmd: *const libc::c_char = 0 as *const libc::c_char;
static mut client_attached: libc::c_int = 0;
static mut client_files: client_files = {
    let mut init = client_files {
        rbh_root: 0 as *const client_file as *mut client_file,
    };
    init
};
unsafe extern "C" fn client_get_lock(mut lockfile: *mut libc::c_char) -> libc::c_int {
    let mut lockfd: libc::c_int = 0;
    log_debug(
        b"lock file is %s\0" as *const u8 as *const libc::c_char,
        lockfile,
    );
    lockfd = open(
        lockfile,
        0o1 as libc::c_int | 0o100 as libc::c_int,
        0o600 as libc::c_int,
    );
    if lockfd == -(1 as libc::c_int) {
        log_debug(
            b"open failed: %s\0" as *const u8 as *const libc::c_char,
            strerror(*__errno_location()),
        );
        return -(1 as libc::c_int);
    }
    if flock(lockfd, 2 as libc::c_int | 4 as libc::c_int) == -(1 as libc::c_int) {
        log_debug(
            b"flock failed: %s\0" as *const u8 as *const libc::c_char,
            strerror(*__errno_location()),
        );
        if *__errno_location() != 11 as libc::c_int {
            return lockfd;
        }
        while flock(lockfd, 2 as libc::c_int) == -(1 as libc::c_int)
            && *__errno_location() == 4 as libc::c_int
        {}
        close(lockfd);
        return -(2 as libc::c_int);
    }
    log_debug(b"flock succeeded\0" as *const u8 as *const libc::c_char);
    return lockfd;
}
unsafe extern "C" fn client_connect(
    mut base: *mut event_base,
    mut path: *const libc::c_char,
    mut flags: uint64_t,
) -> libc::c_int {
    let mut current_block: u64;
    let mut sa: sockaddr_un = sockaddr_un {
        sun_family: 0,
        sun_path: [0; 108],
    };
    let mut size: size_t = 0;
    let mut fd: libc::c_int = 0;
    let mut lockfd: libc::c_int = -(1 as libc::c_int);
    let mut locked: libc::c_int = 0 as libc::c_int;
    let mut lockfile: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    memset(
        &mut sa as *mut sockaddr_un as *mut libc::c_void,
        0 as libc::c_int,
        ::core::mem::size_of::<sockaddr_un>() as libc::c_ulong,
    );
    sa.sun_family = 1 as libc::c_int as sa_family_t;
    size = strlcpy(
        (sa.sun_path).as_mut_ptr(),
        path,
        ::core::mem::size_of::<[libc::c_char; 108]>() as libc::c_ulong,
    );
    if size >= ::core::mem::size_of::<[libc::c_char; 108]>() as libc::c_ulong {
        *__errno_location() = 36 as libc::c_int;
        return -(1 as libc::c_int);
    }
    log_debug(b"socket is %s\0" as *const u8 as *const libc::c_char, path);
    loop {
        fd = socket(
            1 as libc::c_int,
            SOCK_STREAM as libc::c_int,
            0 as libc::c_int,
        );
        if fd == -(1 as libc::c_int) {
            return -(1 as libc::c_int);
        }
        log_debug(b"trying connect\0" as *const u8 as *const libc::c_char);
        if connect(
            fd,
            __CONST_SOCKADDR_ARG {
                __sockaddr__: &mut sa as *mut sockaddr_un as *mut sockaddr,
            },
            ::core::mem::size_of::<sockaddr_un>() as libc::c_ulong as socklen_t,
        ) != -(1 as libc::c_int)
        {
            current_block = 7172762164747879670;
            break;
        }
        log_debug(
            b"connect failed: %s\0" as *const u8 as *const libc::c_char,
            strerror(*__errno_location()),
        );
        if *__errno_location() != 111 as libc::c_int && *__errno_location() != 2 as libc::c_int {
            current_block = 13023870939217044462;
            break;
        }
        if flags & 0x1000 as libc::c_int as libc::c_ulong != 0 {
            current_block = 13023870939217044462;
            break;
        }
        if !flags & 0x10000000 as libc::c_int as libc::c_ulong != 0 {
            current_block = 13023870939217044462;
            break;
        }
        close(fd);
        if locked == 0 {
            xasprintf(
                &mut lockfile as *mut *mut libc::c_char,
                b"%s.lock\0" as *const u8 as *const libc::c_char,
                path,
            );
            lockfd = client_get_lock(lockfile);
            if lockfd < 0 as libc::c_int {
                log_debug(
                    b"didn't get lock (%d)\0" as *const u8 as *const libc::c_char,
                    lockfd,
                );
                free(lockfile as *mut libc::c_void);
                lockfile = std::ptr::null_mut::<libc::c_char>();
                if lockfd == -(2 as libc::c_int) {
                    continue;
                }
            }
            log_debug(
                b"got lock (%d)\0" as *const u8 as *const libc::c_char,
                lockfd,
            );
            locked = 1 as libc::c_int;
        } else {
            if lockfd >= 0 as libc::c_int
                && unlink(path) != 0 as libc::c_int
                && *__errno_location() != 2 as libc::c_int
            {
                free(lockfile as *mut libc::c_void);
                close(lockfd);
                return -(1 as libc::c_int);
            }
            fd = server_start(client_proc, flags, base, lockfd, lockfile);
            current_block = 7172762164747879670;
            break;
        }
    }
    match current_block {
        13023870939217044462 => {
            if locked != 0 {
                free(lockfile as *mut libc::c_void);
                close(lockfd);
            }
            close(fd);
            return -(1 as libc::c_int);
        }
        _ => {
            if locked != 0 && lockfd >= 0 as libc::c_int {
                free(lockfile as *mut libc::c_void);
                close(lockfd);
            }
            setblocking(fd, 0 as libc::c_int);
            return fd;
        }
    };
}
unsafe extern "C" fn client_exit_message() -> *const libc::c_char {
    static mut msg: [libc::c_char; 256] = [0; 256];
    match client_exitreason as libc::c_uint {
        1 => {
            if !client_exitsession.is_null() {
                xsnprintf(
                    msg.as_mut_ptr(),
                    ::core::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong,
                    b"detached (from session %s)\0" as *const u8 as *const libc::c_char,
                    client_exitsession,
                );
                return msg.as_mut_ptr();
            }
            return b"detached\0" as *const u8 as *const libc::c_char;
        }
        2 => {
            if !client_exitsession.is_null() {
                xsnprintf(
                    msg.as_mut_ptr(),
                    ::core::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong,
                    b"detached and SIGHUP (from session %s)\0" as *const u8 as *const libc::c_char,
                    client_exitsession,
                );
                return msg.as_mut_ptr();
            }
            return b"detached and SIGHUP\0" as *const u8 as *const libc::c_char;
        }
        3 => return b"lost tty\0" as *const u8 as *const libc::c_char,
        4 => return b"terminated\0" as *const u8 as *const libc::c_char,
        5 => return b"server exited unexpectedly\0" as *const u8 as *const libc::c_char,
        6 => return b"exited\0" as *const u8 as *const libc::c_char,
        7 => return b"server exited\0" as *const u8 as *const libc::c_char,
        8 => return client_exitmessage,
        0 | _ => {}
    }
    return b"unknown reason\0" as *const u8 as *const libc::c_char;
}
unsafe extern "C" fn client_exit() {
    if file_write_left(&mut client_files) == 0 {
        proc_exit(client_proc);
    }
}
#[no_mangle]
pub unsafe extern "C" fn client_main(
    mut base: *mut event_base,
    mut argc: libc::c_int,
    mut argv: *mut *mut libc::c_char,
    mut flags: uint64_t,
    mut feat: libc::c_int,
) -> libc::c_int {
    let mut pr: *mut cmd_parse_result = std::ptr::null_mut::<cmd_parse_result>();
    let mut data: *mut msg_command = std::ptr::null_mut::<msg_command>();
    let mut fd: libc::c_int = 0;
    let mut i: libc::c_int = 0;
    let mut ttynam: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut termname: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut cwd: *const libc::c_char = std::ptr::null::<libc::c_char>();
    let mut ppid: pid_t = 0;
    let mut msg: msgtype = 0 as msgtype;
    let mut tio: termios = termios {
        c_iflag: 0,
        c_oflag: 0,
        c_cflag: 0,
        c_lflag: 0,
        c_line: 0,
        c_cc: [0; 32],
        c_ispeed: 0,
        c_ospeed: 0,
    };
    let mut saved_tio: termios = termios {
        c_iflag: 0,
        c_oflag: 0,
        c_cflag: 0,
        c_lflag: 0,
        c_line: 0,
        c_cc: [0; 32],
        c_ispeed: 0,
        c_ospeed: 0,
    };
    let mut size: size_t = 0;
    let mut linesize: size_t = 0 as libc::c_int as size_t;
    let mut linelen: ssize_t = 0;
    let mut line: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut caps: *mut *mut libc::c_char = std::ptr::null_mut::<*mut libc::c_char>();
    let mut cause: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut ncaps: u_int = 0 as libc::c_int as u_int;
    let mut values: *mut args_value = std::ptr::null_mut::<args_value>();
    if !shell_command.is_null() {
        msg = MSG_SHELL;
        flags |= 0x10000000 as libc::c_int as libc::c_ulong;
    } else if argc == 0 as libc::c_int {
        msg = MSG_COMMAND;
        flags |= 0x10000000 as libc::c_int as libc::c_ulong;
    } else {
        msg = MSG_COMMAND;
        values = args_from_vector(argc, argv);
        pr = cmd_parse_from_arguments(
            values,
            argc as u_int,
            std::ptr::null_mut::<cmd_parse_input>(),
        );
        if (*pr).status as libc::c_uint == CMD_PARSE_SUCCESS as libc::c_int as libc::c_uint {
            if cmd_list_any_have((*pr).cmdlist, 0x1 as libc::c_int) != 0 {
                flags |= 0x10000000 as libc::c_int as libc::c_ulong;
            }
            cmd_list_free((*pr).cmdlist);
        } else {
            free((*pr).error as *mut libc::c_void);
        }
        args_free_values(values, argc as u_int);
        free(values as *mut libc::c_void);
    }
    client_proc = proc_start(b"client\0" as *const u8 as *const libc::c_char);
    proc_set_signals(
        client_proc,
        Some(client_signal as unsafe extern "C" fn(libc::c_int) -> ()),
    );
    client_flags = flags;
    log_debug(
        b"flags are %#llx\0" as *const u8 as *const libc::c_char,
        client_flags as libc::c_ulonglong,
    );
    fd = client_connect(base, socket_path, client_flags);
    if fd == -(1 as libc::c_int) {
        if *__errno_location() == 111 as libc::c_int {
            fprintf(
                stderr,
                b"no server running on %s\n\0" as *const u8 as *const libc::c_char,
                socket_path,
            );
        } else {
            fprintf(
                stderr,
                b"error connecting to %s (%s)\n\0" as *const u8 as *const libc::c_char,
                socket_path,
                strerror(*__errno_location()),
            );
        }
        return 1 as libc::c_int;
    }
    client_peer = proc_add_peer(
        client_proc,
        fd,
        Some(client_dispatch as unsafe extern "C" fn(*mut imsg, *mut libc::c_void) -> ()),
        std::ptr::null_mut::<libc::c_void>(),
    );
    cwd = find_cwd();
    if cwd.is_null() && {
        cwd = find_home();
        cwd.is_null()
    } {
        cwd = b"/\0" as *const u8 as *const libc::c_char;
    }
    ttynam = ttyname(0 as libc::c_int);
    if ttynam.is_null() {
        ttynam = b"\0" as *const u8 as *const libc::c_char;
    }
    termname = getenv(b"TERM\0" as *const u8 as *const libc::c_char);
    if termname.is_null() {
        termname = b"\0" as *const u8 as *const libc::c_char;
    }
    if 0 as libc::c_int != 0 as libc::c_int {
        fatal(b"pledge failed\0" as *const u8 as *const libc::c_char);
    }
    if isatty(0 as libc::c_int) != 0
        && *termname as libc::c_int != '\0' as i32
        && tty_term_read_list(
            termname,
            0 as libc::c_int,
            &mut caps,
            &mut ncaps,
            &mut cause,
        ) != 0 as libc::c_int
    {
        fprintf(stderr, b"%s\n\0" as *const u8 as *const libc::c_char, cause);
        free(cause as *mut libc::c_void);
        return 1 as libc::c_int;
    }
    if ptm_fd != -(1 as libc::c_int) {
        close(ptm_fd);
    }
    options_free(global_options);
    options_free(global_s_options);
    options_free(global_w_options);
    environ_free(global_environ);
    if client_flags & 0x4000 as libc::c_int as libc::c_ulong != 0 {
        if tcgetattr(0 as libc::c_int, &mut saved_tio) != 0 as libc::c_int {
            fprintf(
                stderr,
                b"tcgetattr failed: %s\n\0" as *const u8 as *const libc::c_char,
                strerror(*__errno_location()),
            );
            return 1 as libc::c_int;
        }
        cfmakeraw(&mut tio);
        tio.c_iflag = (0o400 as libc::c_int | 0o4000 as libc::c_int) as tcflag_t;
        tio.c_oflag = (0o1 as libc::c_int | 0o4 as libc::c_int) as tcflag_t;
        tio.c_cflag =
            (0o200 as libc::c_int | 0o60 as libc::c_int | 0o2000 as libc::c_int) as tcflag_t;
        tio.c_cc[6 as libc::c_int as usize] = 1 as libc::c_int as cc_t;
        tio.c_cc[5 as libc::c_int as usize] = 0 as libc::c_int as cc_t;
        cfsetispeed(&mut tio, cfgetispeed(&mut saved_tio));
        cfsetospeed(&mut tio, cfgetospeed(&mut saved_tio));
        tcsetattr(0 as libc::c_int, 0 as libc::c_int, &mut tio);
    }
    client_send_identify(ttynam, termname, caps, ncaps, cwd, feat);
    tty_term_free_list(caps, ncaps);
    proc_flush_peer(client_peer);
    if msg as libc::c_uint == MSG_COMMAND as libc::c_int as libc::c_uint {
        size = 0 as libc::c_int as size_t;
        i = 0 as libc::c_int;
        while i < argc {
            size = (size as libc::c_ulong).wrapping_add(
                (strlen(*argv.offset(i as isize))).wrapping_add(1 as libc::c_int as libc::c_ulong),
            ) as size_t as size_t;
            i += 1;
        }
        if size
            > (16384 as libc::c_int as libc::c_ulong)
                .wrapping_sub(::core::mem::size_of::<msg_command>() as libc::c_ulong)
        {
            fprintf(
                stderr,
                b"command too long\n\0" as *const u8 as *const libc::c_char,
            );
            return 1 as libc::c_int;
        }
        data = xmalloc((::core::mem::size_of::<msg_command>() as libc::c_ulong).wrapping_add(size))
            as *mut msg_command;
        (*data).argc = argc;
        if cmd_pack_argv(
            argc,
            argv,
            data.offset(1 as libc::c_int as isize) as *mut libc::c_char,
            size,
        ) != 0 as libc::c_int
        {
            fprintf(
                stderr,
                b"command too long\n\0" as *const u8 as *const libc::c_char,
            );
            free(data as *mut libc::c_void);
            return 1 as libc::c_int;
        }
        size = (size as libc::c_ulong)
            .wrapping_add(::core::mem::size_of::<msg_command>() as libc::c_ulong)
            as size_t as size_t;
        if proc_send(
            client_peer,
            msg,
            -(1 as libc::c_int),
            data as *const libc::c_void,
            size,
        ) != 0 as libc::c_int
        {
            fprintf(
                stderr,
                b"failed to send command\n\0" as *const u8 as *const libc::c_char,
            );
            free(data as *mut libc::c_void);
            return 1 as libc::c_int;
        }
        free(data as *mut libc::c_void);
    } else if msg as libc::c_uint == MSG_SHELL as libc::c_int as libc::c_uint {
        proc_send(
            client_peer,
            msg,
            -(1 as libc::c_int),
            std::ptr::null::<libc::c_void>(),
            0 as libc::c_int as size_t,
        );
    }
    proc_loop(client_proc, None);
    if client_exittype as libc::c_uint == MSG_EXEC as libc::c_int as libc::c_uint {
        if client_flags & 0x4000 as libc::c_int as libc::c_ulong != 0 {
            tcsetattr(1 as libc::c_int, 2 as libc::c_int, &mut saved_tio);
        }
        client_exec(client_execshell, client_execcmd);
    }
    setblocking(0 as libc::c_int, 1 as libc::c_int);
    setblocking(1 as libc::c_int, 1 as libc::c_int);
    setblocking(2 as libc::c_int, 1 as libc::c_int);
    if client_attached != 0 {
        if client_exitreason as libc::c_uint != CLIENT_EXIT_NONE as libc::c_int as libc::c_uint {
            printf(
                b"[%s]\n\0" as *const u8 as *const libc::c_char,
                client_exit_message(),
            );
        }
        ppid = getppid();
        if client_exittype as libc::c_uint == MSG_DETACHKILL as libc::c_int as libc::c_uint
            && ppid > 1 as libc::c_int
        {
            kill(ppid, 1 as libc::c_int);
        }
    } else if client_flags & 0x2000 as libc::c_int as libc::c_ulong != 0 {
        if client_exitreason as libc::c_uint != CLIENT_EXIT_NONE as libc::c_int as libc::c_uint {
            printf(
                b"%%exit %s\n\0" as *const u8 as *const libc::c_char,
                client_exit_message(),
            );
        } else {
            printf(b"%%exit\n\0" as *const u8 as *const libc::c_char);
        }
        fflush(stdout);
        if client_flags as libc::c_ulonglong & 0x200000000 as libc::c_ulonglong != 0 {
            setvbuf(
                stdin,
                std::ptr::null_mut::<libc::c_char>(),
                1 as libc::c_int,
                0 as libc::c_int as size_t,
            );
            loop {
                linelen = getline(&mut line, &mut linesize, stdin);
                if linelen <= 1 as libc::c_int as libc::c_long {
                    break;
                }
            }
            free(line as *mut libc::c_void);
        }
        if client_flags & 0x4000 as libc::c_int as libc::c_ulong != 0 {
            printf(b"\x1B\\\0" as *const u8 as *const libc::c_char);
            fflush(stdout);
            tcsetattr(1 as libc::c_int, 2 as libc::c_int, &mut saved_tio);
        }
    } else if client_exitreason as libc::c_uint != CLIENT_EXIT_NONE as libc::c_int as libc::c_uint {
        fprintf(
            stderr,
            b"%s\n\0" as *const u8 as *const libc::c_char,
            client_exit_message(),
        );
    }
    return client_exitval;
}
unsafe extern "C" fn client_send_identify(
    mut ttynam: *const libc::c_char,
    mut termname: *const libc::c_char,
    mut caps: *mut *mut libc::c_char,
    mut ncaps: u_int,
    mut cwd: *const libc::c_char,
    mut feat: libc::c_int,
) {
    let mut ss: *mut *mut libc::c_char = std::ptr::null_mut::<*mut libc::c_char>();
    let mut sslen: size_t = 0;
    let mut fd: libc::c_int = 0;
    let mut flags: uint64_t = client_flags;
    let mut pid: pid_t = 0;
    let mut i: u_int = 0;
    proc_send(
        client_peer,
        MSG_IDENTIFY_LONGFLAGS,
        -(1 as libc::c_int),
        &mut flags as *mut uint64_t as *const libc::c_void,
        ::core::mem::size_of::<uint64_t>() as libc::c_ulong,
    );
    proc_send(
        client_peer,
        MSG_IDENTIFY_LONGFLAGS,
        -(1 as libc::c_int),
        &mut client_flags as *mut uint64_t as *const libc::c_void,
        ::core::mem::size_of::<uint64_t>() as libc::c_ulong,
    );
    proc_send(
        client_peer,
        MSG_IDENTIFY_TERM,
        -(1 as libc::c_int),
        termname as *const libc::c_void,
        (strlen(termname)).wrapping_add(1 as libc::c_int as libc::c_ulong),
    );
    proc_send(
        client_peer,
        MSG_IDENTIFY_FEATURES,
        -(1 as libc::c_int),
        &mut feat as *mut libc::c_int as *const libc::c_void,
        ::core::mem::size_of::<libc::c_int>() as libc::c_ulong,
    );
    proc_send(
        client_peer,
        MSG_IDENTIFY_TTYNAME,
        -(1 as libc::c_int),
        ttynam as *const libc::c_void,
        (strlen(ttynam)).wrapping_add(1 as libc::c_int as libc::c_ulong),
    );
    proc_send(
        client_peer,
        MSG_IDENTIFY_CWD,
        -(1 as libc::c_int),
        cwd as *const libc::c_void,
        (strlen(cwd)).wrapping_add(1 as libc::c_int as libc::c_ulong),
    );
    i = 0 as libc::c_int as u_int;
    while i < ncaps {
        proc_send(
            client_peer,
            MSG_IDENTIFY_TERMINFO,
            -(1 as libc::c_int),
            *caps.offset(i as isize) as *const libc::c_void,
            (strlen(*caps.offset(i as isize))).wrapping_add(1 as libc::c_int as libc::c_ulong),
        );
        i = i.wrapping_add(1);
    }
    fd = dup(0 as libc::c_int);
    if fd == -(1 as libc::c_int) {
        fatal(b"dup failed\0" as *const u8 as *const libc::c_char);
    }
    proc_send(
        client_peer,
        MSG_IDENTIFY_STDIN,
        fd,
        std::ptr::null::<libc::c_void>(),
        0 as libc::c_int as size_t,
    );
    fd = dup(1 as libc::c_int);
    if fd == -(1 as libc::c_int) {
        fatal(b"dup failed\0" as *const u8 as *const libc::c_char);
    }
    proc_send(
        client_peer,
        MSG_IDENTIFY_STDOUT,
        fd,
        std::ptr::null::<libc::c_void>(),
        0 as libc::c_int as size_t,
    );
    pid = getpid();
    proc_send(
        client_peer,
        MSG_IDENTIFY_CLIENTPID,
        -(1 as libc::c_int),
        &mut pid as *mut pid_t as *const libc::c_void,
        ::core::mem::size_of::<pid_t>() as libc::c_ulong,
    );
    ss = environ;
    while !(*ss).is_null() {
        sslen = (strlen(*ss)).wrapping_add(1 as libc::c_int as libc::c_ulong);
        if sslen
            <= (16384 as libc::c_int as libc::c_ulong)
                .wrapping_sub(::core::mem::size_of::<imsg_hdr>() as libc::c_ulong)
        {
            proc_send(
                client_peer,
                MSG_IDENTIFY_ENVIRON,
                -(1 as libc::c_int),
                *ss as *const libc::c_void,
                sslen,
            );
        }
        ss = ss.offset(1);
    }
    proc_send(
        client_peer,
        MSG_IDENTIFY_DONE,
        -(1 as libc::c_int),
        std::ptr::null::<libc::c_void>(),
        0 as libc::c_int as size_t,
    );
}
unsafe extern "C" fn client_exec(
    mut shell: *const libc::c_char,
    mut shellcmd: *const libc::c_char,
) -> ! {
    let mut argv0: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    log_debug(
        b"shell %s, command %s\0" as *const u8 as *const libc::c_char,
        shell,
        shellcmd,
    );
    argv0 = shell_argv0(
        shell,
        (client_flags & 0x2 as libc::c_int as libc::c_ulong != 0) as libc::c_int,
    );
    setenv(
        b"SHELL\0" as *const u8 as *const libc::c_char,
        shell,
        1 as libc::c_int,
    );
    proc_clear_signals(client_proc, 1 as libc::c_int);
    setblocking(0 as libc::c_int, 1 as libc::c_int);
    setblocking(1 as libc::c_int, 1 as libc::c_int);
    setblocking(2 as libc::c_int, 1 as libc::c_int);
    closefrom(2 as libc::c_int + 1 as libc::c_int);
    execl(
        shell,
        argv0,
        b"-c\0" as *const u8 as *const libc::c_char,
        shellcmd,
        std::ptr::null_mut::<libc::c_void>() as *mut libc::c_char,
    );
    fatal(b"execl failed\0" as *const u8 as *const libc::c_char);
}
unsafe extern "C" fn client_signal(mut sig: libc::c_int) {
    let mut sigact: sigaction = sigaction {
        __sigaction_handler: C2RustUnnamed_10 { sa_handler: None },
        sa_mask: __sigset_t { __val: [0; 16] },
        sa_flags: 0,
        sa_restorer: None,
    };
    let mut status: libc::c_int = 0;
    let mut pid: pid_t = 0;
    log_debug(
        b"%s: %s\0" as *const u8 as *const libc::c_char,
        (*::core::mem::transmute::<&[u8; 14], &[libc::c_char; 14]>(b"client_signal\0")).as_ptr(),
        strsignal(sig),
    );
    if sig == 17 as libc::c_int {
        loop {
            pid = waitpid(-(1 as libc::c_int), &mut status, 1 as libc::c_int);
            if pid == 0 as libc::c_int {
                break;
            }
            if pid != -(1 as libc::c_int) {
                continue;
            }
            if *__errno_location() == 10 as libc::c_int {
                break;
            }
            log_debug(
                b"waitpid failed: %s\0" as *const u8 as *const libc::c_char,
                strerror(*__errno_location()),
            );
        }
    } else if client_attached == 0 {
        if sig == 15 as libc::c_int || sig == 1 as libc::c_int {
            proc_exit(client_proc);
        }
    } else {
        match sig {
            1 => {
                client_exitreason = CLIENT_EXIT_LOST_TTY;
                client_exitval = 1 as libc::c_int;
                proc_send(
                    client_peer,
                    MSG_EXITING,
                    -(1 as libc::c_int),
                    std::ptr::null::<libc::c_void>(),
                    0 as libc::c_int as size_t,
                );
            }
            15 => {
                if client_suspended == 0 {
                    client_exitreason = CLIENT_EXIT_TERMINATED;
                }
                client_exitval = 1 as libc::c_int;
                proc_send(
                    client_peer,
                    MSG_EXITING,
                    -(1 as libc::c_int),
                    std::ptr::null::<libc::c_void>(),
                    0 as libc::c_int as size_t,
                );
            }
            28 => {
                proc_send(
                    client_peer,
                    MSG_RESIZE,
                    -(1 as libc::c_int),
                    std::ptr::null::<libc::c_void>(),
                    0 as libc::c_int as size_t,
                );
            }
            18 => {
                memset(
                    &mut sigact as *mut sigaction as *mut libc::c_void,
                    0 as libc::c_int,
                    ::core::mem::size_of::<sigaction>() as libc::c_ulong,
                );
                sigemptyset(&mut sigact.sa_mask);
                sigact.sa_flags = 0x10000000 as libc::c_int;
                sigact.__sigaction_handler.sa_handler =
                    ::core::mem::transmute::<libc::intptr_t, __sighandler_t>(
                        1 as libc::c_int as libc::intptr_t,
                    );
                if sigaction(
                    20 as libc::c_int,
                    &mut sigact,
                    std::ptr::null_mut::<sigaction>(),
                ) != 0 as libc::c_int
                {
                    fatal(b"sigaction failed\0" as *const u8 as *const libc::c_char);
                }
                proc_send(
                    client_peer,
                    MSG_WAKEUP,
                    -(1 as libc::c_int),
                    std::ptr::null::<libc::c_void>(),
                    0 as libc::c_int as size_t,
                );
                client_suspended = 0 as libc::c_int;
            }
            _ => {}
        }
    };
}
unsafe extern "C" fn client_file_check_cb(
    mut c: *mut client,
    mut path: *const libc::c_char,
    mut error: libc::c_int,
    mut closed: libc::c_int,
    mut buffer: *mut evbuffer,
    mut data: *mut libc::c_void,
) {
    if client_exitflag != 0 {
        client_exit();
    }
}
unsafe extern "C" fn client_dispatch(mut imsg: *mut imsg, mut arg: *mut libc::c_void) {
    if imsg.is_null() {
        if client_exitflag == 0 {
            client_exitreason = CLIENT_EXIT_LOST_SERVER;
            client_exitval = 1 as libc::c_int;
        }
        proc_exit(client_proc);
        return;
    }
    if client_attached != 0 {
        client_dispatch_attached(imsg);
    } else {
        client_dispatch_wait(imsg);
    };
}
unsafe extern "C" fn client_dispatch_exit_message(
    mut data: *mut libc::c_char,
    mut datalen: size_t,
) {
    let mut retval: libc::c_int = 0;
    if datalen < ::core::mem::size_of::<libc::c_int>() as libc::c_ulong
        && datalen != 0 as libc::c_int as libc::c_ulong
    {
        fatalx(b"bad MSG_EXIT size\0" as *const u8 as *const libc::c_char);
    }
    if datalen >= ::core::mem::size_of::<libc::c_int>() as libc::c_ulong {
        memcpy(
            &mut retval as *mut libc::c_int as *mut libc::c_void,
            data as *const libc::c_void,
            ::core::mem::size_of::<libc::c_int>() as libc::c_ulong,
        );
        client_exitval = retval;
    }
    if datalen > ::core::mem::size_of::<libc::c_int>() as libc::c_ulong {
        datalen = (datalen as libc::c_ulong)
            .wrapping_sub(::core::mem::size_of::<libc::c_int>() as libc::c_ulong)
            as size_t as size_t;
        data = data.offset(::core::mem::size_of::<libc::c_int>() as libc::c_ulong as isize);
        client_exitmessage = xmalloc(datalen) as *mut libc::c_char;
        memcpy(
            client_exitmessage as *mut libc::c_void,
            data as *const libc::c_void,
            datalen,
        );
        *client_exitmessage
            .offset(datalen.wrapping_sub(1 as libc::c_int as libc::c_ulong) as isize) =
            '\0' as i32 as libc::c_char;
        client_exitreason = CLIENT_EXIT_MESSAGE_PROVIDED;
    }
}
unsafe extern "C" fn client_dispatch_wait(mut imsg: *mut imsg) {
    let mut data: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut datalen: ssize_t = 0;
    static mut pledge_applied: libc::c_int = 0;
    if pledge_applied == 0 {
        if 0 as libc::c_int != 0 as libc::c_int {
            fatal(b"pledge failed\0" as *const u8 as *const libc::c_char);
        }
        pledge_applied = 1 as libc::c_int;
    }
    data = (*imsg).data as *mut libc::c_char;
    datalen = ((*imsg).hdr.len as libc::c_ulong)
        .wrapping_sub(::core::mem::size_of::<imsg_hdr>() as libc::c_ulong) as ssize_t;
    match (*imsg).hdr.type_0 {
        203 | 210 => {
            client_dispatch_exit_message(data, datalen as size_t);
            client_exitflag = 1 as libc::c_int;
            client_exit();
        }
        207 => {
            if datalen != 0 as libc::c_int as libc::c_long {
                fatalx(b"bad MSG_READY size\0" as *const u8 as *const libc::c_char);
            }
            client_attached = 1 as libc::c_int;
            proc_send(
                client_peer,
                MSG_RESIZE,
                -(1 as libc::c_int),
                std::ptr::null::<libc::c_void>(),
                0 as libc::c_int as size_t,
            );
        }
        12 => {
            if datalen != 0 as libc::c_int as libc::c_long {
                fatalx(b"bad MSG_VERSION size\0" as *const u8 as *const libc::c_char);
            }
            fprintf(
                stderr,
                b"protocol version mismatch (client %d, server %u)\n\0" as *const u8
                    as *const libc::c_char,
                8 as libc::c_int,
                (*imsg).hdr.peerid & 0xff as libc::c_int as libc::c_uint,
            );
            client_exitval = 1 as libc::c_int;
            proc_exit(client_proc);
        }
        218 => {
            if datalen as libc::c_ulong != ::core::mem::size_of::<uint64_t>() as libc::c_ulong {
                fatalx(b"bad MSG_FLAGS string\0" as *const u8 as *const libc::c_char);
            }
            memcpy(
                &mut client_flags as *mut uint64_t as *mut libc::c_void,
                data as *const libc::c_void,
                ::core::mem::size_of::<uint64_t>() as libc::c_ulong,
            );
            log_debug(
                b"new flags are %#llx\0" as *const u8 as *const libc::c_char,
                client_flags as libc::c_ulonglong,
            );
        }
        209 => {
            if datalen == 0 as libc::c_int as libc::c_long
                || *data.offset((datalen - 1 as libc::c_int as libc::c_long) as isize)
                    as libc::c_int
                    != '\0' as i32
            {
                fatalx(b"bad MSG_SHELL string\0" as *const u8 as *const libc::c_char);
            }
            client_exec(data, shell_command);
        }
        201 | 202 => {
            proc_send(
                client_peer,
                MSG_EXITING,
                -(1 as libc::c_int),
                std::ptr::null::<libc::c_void>(),
                0 as libc::c_int as size_t,
            );
        }
        204 => {
            proc_exit(client_proc);
        }
        300 => {
            file_read_open(
                &mut client_files,
                client_peer,
                imsg,
                1 as libc::c_int,
                (client_flags & 0x2000 as libc::c_int as libc::c_ulong == 0) as libc::c_int,
                Some(
                    client_file_check_cb
                        as unsafe extern "C" fn(
                            *mut client,
                            *const libc::c_char,
                            libc::c_int,
                            libc::c_int,
                            *mut evbuffer,
                            *mut libc::c_void,
                        ) -> (),
                ),
                std::ptr::null_mut::<libc::c_void>(),
            );
        }
        307 => {
            file_read_cancel(&mut client_files, imsg);
        }
        303 => {
            file_write_open(
                &mut client_files,
                client_peer,
                imsg,
                1 as libc::c_int,
                (client_flags & 0x2000 as libc::c_int as libc::c_ulong == 0) as libc::c_int,
                Some(
                    client_file_check_cb
                        as unsafe extern "C" fn(
                            *mut client,
                            *const libc::c_char,
                            libc::c_int,
                            libc::c_int,
                            *mut evbuffer,
                            *mut libc::c_void,
                        ) -> (),
                ),
                std::ptr::null_mut::<libc::c_void>(),
            );
        }
        304 => {
            file_write_data(&mut client_files, imsg);
        }
        306 => {
            file_write_close(&mut client_files, imsg);
        }
        211 | 212 | 213 => {
            fprintf(
                stderr,
                b"server version is too old for client\n\0" as *const u8 as *const libc::c_char,
            );
            proc_exit(client_proc);
        }
        _ => {}
    };
}
unsafe extern "C" fn client_dispatch_attached(mut imsg: *mut imsg) {
    let mut sigact: sigaction = sigaction {
        __sigaction_handler: C2RustUnnamed_10 { sa_handler: None },
        sa_mask: __sigset_t { __val: [0; 16] },
        sa_flags: 0,
        sa_restorer: None,
    };
    let mut data: *mut libc::c_char = std::ptr::null_mut::<libc::c_char>();
    let mut datalen: ssize_t = 0;
    data = (*imsg).data as *mut libc::c_char;
    datalen = ((*imsg).hdr.len as libc::c_ulong)
        .wrapping_sub(::core::mem::size_of::<imsg_hdr>() as libc::c_ulong) as ssize_t;
    match (*imsg).hdr.type_0 {
        218 => {
            if datalen as libc::c_ulong != ::core::mem::size_of::<uint64_t>() as libc::c_ulong {
                fatalx(b"bad MSG_FLAGS string\0" as *const u8 as *const libc::c_char);
            }
            memcpy(
                &mut client_flags as *mut uint64_t as *mut libc::c_void,
                data as *const libc::c_void,
                ::core::mem::size_of::<uint64_t>() as libc::c_ulong,
            );
            log_debug(
                b"new flags are %#llx\0" as *const u8 as *const libc::c_char,
                client_flags as libc::c_ulonglong,
            );
        }
        201 | 202 => {
            if datalen == 0 as libc::c_int as libc::c_long
                || *data.offset((datalen - 1 as libc::c_int as libc::c_long) as isize)
                    as libc::c_int
                    != '\0' as i32
            {
                fatalx(b"bad MSG_DETACH string\0" as *const u8 as *const libc::c_char);
            }
            client_exitsession = xstrdup(data);
            client_exittype = (*imsg).hdr.type_0 as msgtype;
            if (*imsg).hdr.type_0 == MSG_DETACHKILL as libc::c_int as libc::c_uint {
                client_exitreason = CLIENT_EXIT_DETACHED_HUP;
            } else {
                client_exitreason = CLIENT_EXIT_DETACHED;
            }
            proc_send(
                client_peer,
                MSG_EXITING,
                -(1 as libc::c_int),
                std::ptr::null::<libc::c_void>(),
                0 as libc::c_int as size_t,
            );
        }
        217 => {
            if datalen == 0 as libc::c_int as libc::c_long
                || *data.offset((datalen - 1 as libc::c_int as libc::c_long) as isize)
                    as libc::c_int
                    != '\0' as i32
                || (strlen(data)).wrapping_add(1 as libc::c_int as libc::c_ulong)
                    == datalen as size_t
            {
                fatalx(b"bad MSG_EXEC string\0" as *const u8 as *const libc::c_char);
            }
            client_execcmd = xstrdup(data);
            client_execshell = xstrdup(
                data.offset(strlen(data) as isize)
                    .offset(1 as libc::c_int as isize),
            );
            client_exittype = (*imsg).hdr.type_0 as msgtype;
            proc_send(
                client_peer,
                MSG_EXITING,
                -(1 as libc::c_int),
                std::ptr::null::<libc::c_void>(),
                0 as libc::c_int as size_t,
            );
        }
        203 => {
            client_dispatch_exit_message(data, datalen as size_t);
            if client_exitreason as libc::c_uint == CLIENT_EXIT_NONE as libc::c_int as libc::c_uint
            {
                client_exitreason = CLIENT_EXIT_EXITED;
            }
            proc_send(
                client_peer,
                MSG_EXITING,
                -(1 as libc::c_int),
                std::ptr::null::<libc::c_void>(),
                0 as libc::c_int as size_t,
            );
        }
        204 => {
            if datalen != 0 as libc::c_int as libc::c_long {
                fatalx(b"bad MSG_EXITED size\0" as *const u8 as *const libc::c_char);
            }
            proc_exit(client_proc);
        }
        210 => {
            if datalen != 0 as libc::c_int as libc::c_long {
                fatalx(b"bad MSG_SHUTDOWN size\0" as *const u8 as *const libc::c_char);
            }
            proc_send(
                client_peer,
                MSG_EXITING,
                -(1 as libc::c_int),
                std::ptr::null::<libc::c_void>(),
                0 as libc::c_int as size_t,
            );
            client_exitreason = CLIENT_EXIT_SERVER_EXITED;
            client_exitval = 1 as libc::c_int;
        }
        214 => {
            if datalen != 0 as libc::c_int as libc::c_long {
                fatalx(b"bad MSG_SUSPEND size\0" as *const u8 as *const libc::c_char);
            }
            memset(
                &mut sigact as *mut sigaction as *mut libc::c_void,
                0 as libc::c_int,
                ::core::mem::size_of::<sigaction>() as libc::c_ulong,
            );
            sigemptyset(&mut sigact.sa_mask);
            sigact.sa_flags = 0x10000000 as libc::c_int;
            sigact.__sigaction_handler.sa_handler = None;
            if sigaction(
                20 as libc::c_int,
                &mut sigact,
                std::ptr::null_mut::<sigaction>(),
            ) != 0 as libc::c_int
            {
                fatal(b"sigaction failed\0" as *const u8 as *const libc::c_char);
            }
            client_suspended = 1 as libc::c_int;
            kill(getpid(), 20 as libc::c_int);
        }
        206 => {
            if datalen == 0 as libc::c_int as libc::c_long
                || *data.offset((datalen - 1 as libc::c_int as libc::c_long) as isize)
                    as libc::c_int
                    != '\0' as i32
            {
                fatalx(b"bad MSG_LOCK string\0" as *const u8 as *const libc::c_char);
            }
            system(data);
            proc_send(
                client_peer,
                MSG_UNLOCK,
                -(1 as libc::c_int),
                std::ptr::null::<libc::c_void>(),
                0 as libc::c_int as size_t,
            );
        }
        _ => {}
    };
}
